#include "app.hpp"
#include <iostream>


app::app(int age, std::string name)
{
    m_age = age;
    m_name = name;
    
    std::cout<<"app construct"<<std::endl;
}

app::~app()
{
    
    std::cout<<"app destruct"<<std::endl;
}

void app::Print_1()
{
    std::cout<<"Print_1 task - "<<execute_cnt<<std::endl;
    execute_cnt++;
}

void app::Print_2()
{
    std::cout<<"age = "<<this->m_age<<" name = "<<this->m_name <<std::endl;
}

void app::task_1()
{
    //executor_.Runtask([this]() { Print_1(); });
    
    //executor_.Runtask([](){std::cout<<"executor_ task";});
    int Print_cnt = 9;
    for(;;)
    {
        executor_.Runtask(std::bind(&app::Print_1,this));
        std::this_thread::sleep_for(std::chrono::seconds(1));

        if(! (Print_cnt--))
            break;
    }
}

void app::task_2()
{
    executor_.Runtask(std::bind(&app::Print_2,this));
}
